const promise = new Promise((resolve, reject) => {
  setTimeout(() => {
    let error = true;

    if (!error) {
      resolve({ name: 'John', age: 30 });
    } else {
      reject('出现了问题');
    }
  }, 1000);
});

promise
  .then((user) => {
    console.log(user);
    return user.name;
  })
  .then(name => {
    console.log(name);
    return name.length;
    })

    .then(nameLength => {
      console.log(nameLength);
      })
      .catch(error => {
       console.log(error);
       return 123;
      })
       .then((x) => console.log('无论发生什么这都会运行',x));
   
 
